/**
 入驻小区
 **/
(function (vc) {
    let DEFAULT_PAGE = 1;
    let DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aWorkDetailTaskItemInfo: {
                tasks: [],
                workId: '',
                taskId: '',
                items: []
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('aWorkDetailTaskItem', 'switch', function (_data) {
                $that.aWorkDetailTaskItemInfo.workId = _data.workId;
                $that._queryWorkDetailTaskData();
            });
            vc.on('aWorkDetailTaskItem', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadWorkDetailTaskData(_currentPage, DEFAULT_ROWS);
                });
            vc.on('aWorkDetailTaskItem', 'notify', function (_data) {
                $that._loadWorkDetailTaskData(DEFAULT_PAGE, DEFAULT_ROWS);
            })
        },
        methods: {
            _queryWorkDetailTaskData: function () {
                let param = {
                    params: {
                        workId: $that.aWorkDetailTaskItemInfo.workId,
                        page: 1,
                        row: 100
                    }
                };
                //发送get请求
                vc.http.apiGet('/work.listAdminWorkTask',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.aWorkDetailTaskItemInfo.tasks = _json.data;
                        $that.swatchTaskItemTaskId(_json.data[0]);
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            _loadAWorkDetailTaskItemData: function () {
                let param = {
                    params: {
                        workId: $that.aWorkDetailTaskItemInfo.workId,
                        taskId: $that.aWorkDetailTaskItemInfo.taskId,
                        page: 1,
                        row: 100
                    }
                };
                //发送get请求
                vc.http.apiGet('/task.listAdminWorkTaskItem',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.aWorkDetailTaskItemInfo.items = _json.data;
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            swatchTaskItemTaskId: function (_task) {
                $that.aWorkDetailTaskItemInfo.taskId = _task.taskId;
                $that._loadAWorkDetailTaskItemData();
            },
        }
    });
})(window.vc);